<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script src="js/axios-0.18.0.js"></script>

用户名：<input type="text" name="usernaem"><br>
密码：<input type="password" name="password"><br>
地址：<select id="select">

</select>
<select id="selectcity">

</select><br>
<input type="submit">

<script>
    window.onload= function () {
        axios.get("http://localhost:8080/review/provinceServlet")
            .then(resp => {
                let array = resp.data;
                let str = "";

                for (let i = 0; i < array.length; i++) {
                    var element = array[i];
                    var id1 = ''+element.id;
                    str += "<option name='province' value="+id1+" >" + array[i].province + "</option>"
                }
                document.getElementById("select").innerHTML=str;
            })

    }
/*
    document.getElementById("select").onload = function () {
        let id = this.value;
        axios.post("http://localhost:8080/review/cityServlet","id="+id)
            .then( resp => {
                let c = resp.data;
                let str = "";
                for (let i = 0; i < c.length; i++) {
                    str += "<option name='city' value="+c[i].id+">" +c[i].city+ "</option>>"
                }
                document.getElementById("selectcity").innerHTML = str;
            })
    }*/

    document.getElementById("select").onblur = function () {
        let id = this.value;
        axios.post("http://localhost:8080/review/cityServlet","id="+id)
            .then( resp => {
                let c = resp.data;
                let str = "";
                for (let i = 0; i < c.length; i++) {
                    str += "<option name='city' value=" +c[i].id + ">" +c[i].city+ "</option>>"
                }
                document.getElementById("selectcity").innerHTML = str;
            })
    }




</script>

</body>
</html>